def insertion_sort(arr):
    for i in range(1, len(arr)):
        current = arr[i]
        j = i - 1
        # 如果前一个数比当前大，就往后移动
        while j >= 0 and arr[j] > current:
            arr[j + 1] = arr[j]
            j -= 1
        # 插入当前元素
        arr[j + 1] = current
    return arr

if __name__ == '__main__':
    arr=[1,3,5,2,4,6]
    print(insertion_sort(arr))
